const { readFile } = require('fs')
const { promisify } = require('util')
const readFilePromise = promisify(readFile)

// 串行
async function getData() {
  console.time('time')
  let data1 = await readFilePromise('./1.txt', 'utf-8')
  let data2 = await readFilePromise('./2.txt', 'utf-8')
  console.timeEnd('time')
}
// 并发
// async function getData() {
//   console.time('time')
//   let promise1 = readFilePromise('./1.txt', 'utf-8')
//   let promise2 = readFilePromise('./2.txt', 'utf-8')
//   // 并发
//   let data = await Promise.all([promise1, promise2])
//   console.timeEnd('time')
// }

getData()
